﻿// 2023/11/14: 首个记录。基于v1 2023/11/1版本，增加分类置信度和描述信息字段，distance改为可选字段
// 2024/7/3: 基于新样本框架。枚举改为使用enum class
// 2025/3/25: 实现fromSample
// 2025/3/26: 实现getProtocolNames
// 2025/4/8: 修正description字段解析
// 2025/4/18: 增加仪表盘标识大类
// 2025/4/19: 修正fromSample
// 2025/8/4: 不使用cat宏
// 2025/8/4: 修正fromSample未赋值时间戳问题

#ifndef IMAGE_LABEL_SAMPLE_V2_H
#define IMAGE_LABEL_SAMPLE_V2_H

#include "spadas.h"

namespace image_label_sample_v2
{
	using namespace spadas;

	enum class LabelClass
	{
		Unknown = 0, // 未知

		GeneralCar = 100, // General automobile / 机动车大类
		Car = 101, // 轿车
		Bus = 102,// 大巴
		Midibus = 103,// 小巴
		Truck = 104, // 货车
		Van = 105, // 面包车
		Semitrailer = 106, // 货柜车
		Trailer = 107, // 拖车
		SUV = 108, // SUV
		TinyCar = 109, // 微型车

		GeneralMinority = 200, // General vulnerable road user / 弱势参与者大类
		Pedestrian = 201, // Pedestrian / 行人
		Bicycle = 202, // 自行车
		Tricycle = 203, // 三轮车
		Motorbike = 204, // 摩托车
		Wheelchair = 205, // 轮椅
		Animal = 206, // 动物

		GeneralStatic = 300, // General static object / 静态目标大类
		ZebraCrossing = 301, // 斑马线
		TrafficLight = 302, // 交通灯
		TrafficSign = 303, // 交通信号
		ParkingSlot = 304, // 车位
		Cone = 305, // 锥形路障
		ManholeCover = 306, // 井盖
		Patch = 307, // 路面补丁
		Gantry = 308, // 龙门架
		Pole = 309, // 竖杆
		Tree = 310, // 树木
		Vegetation = 311, // 灌木
		Building = 312, // 建筑物

		Dashboard = 1000, // Dashboard signal / 仪表盘标识大类
		Airbag = 1001, // 安全气囊
		ABS = 1002, // 防抱死制动
		BrakeSystemFailure = 1003, // 刹车系统故障
		ChargingSystemFailure = 1004, // 充电系统故障
		CentralWarningLamp = 1005, // 中央警告灯
		CoolingSystemFailure = 1006, // 冷却系统故障
		DoorsOpen = 1007, // 车门未关
		ElectronicPowerSteering = 1008, // 转向助力
		ElectronicStability = 1009, // 电子稳定性(ESC)
		EnginePreheating = 1010, // 发动机预热
		FrontFogLight = 1011, // 前雾灯
		LaneDepartureWarning = 1012, // 车道偏离预警
		LowBeam = 1013, // 近光灯
		LowEngineOilWarning = 1014, // 低燃油警告
		SeatBelt = 1015, // 安全带提醒
		SideLamp = 1016, // 示廓灯
		TyrePressureMonitoring = 1017, // 胎压异常
		WasherFluid = 1018, // 玻璃水不足
	};

	struct ImageLabel
	{
		UInt id; // 标签ID
		LabelClass clas; // 标签类型
		OptionalDouble classConfidence; // [%] Classification confidence / 分类置信度
		OptionalDouble distance; // [m] Average distance between the label's pixels to the camera (along x axis of camera coordinate system) / 标签距摄像头的平均距离（沿摄像头x轴方向）
		Point2D topLeft; // [pix] Coordination of the top left point of label's border / 标签矩形框的左上角坐标
		Point2D bottomRight; // [pix] Coordination of the bottom right point of label's border / 标签矩形框的右下角坐标
		String description; // 描述信息
	};

	struct ImageLabelSampleData
	{
		UInt channel; // Corresponding video channel / 对应的视频通道
		Size2D imageSize; // [pix] 图像尺寸
		Array<ImageLabel> labels; // List of labels / 标签列表

		ImageLabelSampleData()
		{
			channel = UINF;
		}
	};

	class ImageLabelSample : public Object<class ImageLabelSampleVars>
	{
	public:
		SPADAS_TYPE("image_label_sample_v2.ImageLabelSample")

		ImageLabelSample();
		FullTimestamp& timestamp();
		ImageLabelSampleData *operator ->();

		static String getProtocolName(UInt channel);
		SessionGeneralSample toGeneralSample();

		static Array<String> getProtocolNames(UInt channel);
		Bool fromGeneralSample(String protocol, SessionGeneralSample generalSample);
	};
}

#endif